package com.jeesite.modules.dataScreen.web;


import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeesite.modules.dataScreen.service.EventConductService;
import com.jeesite.modules.dataScreen.web.vo.Result;
import com.jeesite.modules.dataScreen.web.vo.TrafficDTO;
import com.jeesite.modules.dataScreen.web.vo.event.EventConductCellVo;
import com.jeesite.modules.dataScreen.web.vo.event.EventConductVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Api(tags = "首页-事件处置")
@RequestMapping("/events")
public class EventConductApi {
    @Resource
    private EventConductService eventConductService;

    @GetMapping("/list")
    @ApiOperation("事件处置-右侧列表")
    @ApiImplicitParam(name = "keywords",value = "年,季,月,周，今日")
    public Result<IPage<EventConductVo>> eventList(@RequestParam(defaultValue = "1") int pageNum,
                                                   @RequestParam(defaultValue = "10") int pageSize,
                                                   @RequestParam String keywords) {
        Page<EventConductVo> page = new Page<>(pageNum, pageSize);
        return Result.OK(eventConductService.eventList(page,keywords));
    }

    @GetMapping("/items")
    @ApiOperation("事件处置-左侧接口")
    public Result<EventConductCellVo> cellItem() {
        return Result.OK(eventConductService.cellItem());
    }

    @GetMapping("/windowList")
    @ApiOperation("事件处置-弹窗列表")
    @ApiImplicitParam(name = "keywords",value = "年,季,月,周，今日")
    public Result<IPage<EventConductVo>> windowList(@RequestParam(defaultValue = "1") int pageNum,
                                                    @RequestParam(defaultValue = "10") int pageSize,
                                                    @RequestParam(required = false) String mainType,
                                                    @RequestParam(defaultValue = "allStatus") String status,
                                                    @RequestParam(required = false) String name,
                                                    @RequestParam(required = false) String start,
                                                    @RequestParam(required = false) String end,
                                                    @RequestParam(required = false) String level, String keywords
    ) {
        Page<EventConductVo> page = new Page<>(pageNum, pageSize);
        return Result.OK(eventConductService.windowList(page, mainType, status, name, start, end,level,keywords));
    }

    @GetMapping("/incidentNumber")
    @ApiOperation("突发时间数量")
    public Result<List<EventConductVo>> incidentNumber(@RequestParam String keywords) {

        return Result.OK(eventConductService.incidentNumber(keywords));
    }

    @GetMapping("/eventDetails")
    @ApiOperation("事件详情弹窗")
    public Result<List<TrafficDTO>> eventDetails(@RequestParam(defaultValue = "1") int oid,String sjyptid) {

        return Result.OK(eventConductService.eventDetails(oid,sjyptid));
    }

    @GetMapping("/levelCount")
    @ApiOperation("事件处置-事件等级数量")
    @ApiImplicitParam(name = "status",value = "0:处置中,1:已完结",required = true,dataType = "int")
    public Result<List<JSONObject>> levelCount(@RequestParam int status,String keywords) {

        return Result.OK(eventConductService.levelCount(status, keywords));
    }

    @GetMapping("/eventInformation")
    @ApiOperation("事件信息")
    public Result<List<JSONObject>> eventInformation(@RequestParam(required = true) String oid) {
        return Result.OK(eventConductService.eventInformation(oid));
    }
}
